<template>
    <div class="app-container">
        <div class="customContainer">
            <div class="store">
                <el-form size="small">
                    <el-form-item>
                        <el-select
                                placeholder="选择门店"
                                v-model="store_id"
                                @change="storeClearDate"
                                style="width:300px"
                                filterable>
                            <el-option
                                    v-for="item in store_list"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                </el-form>
            </div>
            <div class="main">
                <div class="tag_menu">
                    <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
                        <el-menu-item index="1">生日福利</el-menu-item>
                        <el-menu-item index="2">办卡升级福利</el-menu-item>
                        <el-menu-item index="3">彩豆兑换折扣</el-menu-item>
                        <el-menu-item index="4">支持积分升级</el-menu-item>
                        <el-menu-item index="5">取卡全场播报</el-menu-item>
                    </el-menu>
                </div>
                <div class="centent">
                    <div v-show="activeIndex==1">
                        <div v-for="(item,index) in birthday" :key="index" class="birthday">
                            <div class="op_title">
                                <span>{{item.name}}</span>
                                <el-button  v-if="item.list.length<=0" @click="addBirthday(item.name,index)">添加</el-button>
                                <el-button  v-else @click="alterDialog(item.name,index)">修改</el-button>
                                <span class="text">{{item.title}}</span>
                            </div>
                            <el-table stripe highlight-current-row :data="item.list" border size="mini" v-if="item.list.length>0" class="table">
                                <el-table-column align="center" label='序号' width="50">
                                    <template slot-scope="scope">{{scope.$index+1+(currentPage-1)*20}}</template>
                                </el-table-column>
                                <el-table-column align="center" label="商品名称" prop="name"></el-table-column>
                                <el-table-column align="center" label="类型" prop="type_name"></el-table-column>
                                <el-table-column align="center" label="有效期" prop="time"></el-table-column>
                                <el-table-column align="center" label="限购数量" prop="limit_num"></el-table-column>
                            </el-table>
                        </div>
                    </div>
                    <div v-show="activeIndex==2">
                        <div v-for="(item,index) in applyCard" :key="index" class="birthday">
                            <div class="op_title">
                                <span>{{item.name}}</span>
                                <el-button  v-if="item.list.length<=0" @click="addBirthday(item.name,index)">添加</el-button>
                                <el-button  v-else @click="alterDialog(item.name,index)">修改</el-button>
                                <span class="text">{{item.title}}</span>
                            </div>
                            <el-table stripe highlight-current-row :data="item.list" border size="mini" v-if="item.list.length>0" class="table">
                                <el-table-column align="center" label='序号' width="50">
                                    <template slot-scope="scope">{{scope.$index+1+(currentPage-1)*20}}</template>
                                </el-table-column>
                                <el-table-column align="center" label="商品名称" prop="name"></el-table-column>
                                <el-table-column align="center" label="类型" prop="type_name"></el-table-column>
                                <el-table-column align="center" label="有效期" prop="time"></el-table-column>
                                <el-table-column align="center" label="限购数量" prop="limit_num"></el-table-column>
                            </el-table>
                        </div>
                    </div>
                    <div v-show="activeIndex==3">
                        <div v-for="(item,index) in colorFilm" :key="index" class="birthday">
                            <div class="op_title">{{item.name}}</div>
                            <div class="main">
                                <el-checkbox-group v-model="colorFilmList">
                                    <el-checkbox :label="item.name" name="type" :disabled="modification"></el-checkbox>
                                </el-checkbox-group>
                                <p v-if="colorFilmList.includes(item.name)">彩豆（票）享
                                    <el-input :disabled="modification" type="text" @input="inputValue(index)" style="width: 250px;margin: 0 15px" v-model="item.number" placeholder="0.1 ~ 9.9"></el-input>折，<span class="text">{{item.title}}</span></p>
                            </div>
                        </div>
                    </div>
                    <div v-show="activeIndex==4">
                        <div v-for="(item,index) in integral" :key="index" class="birthday">
                            <div class="op_title">{{item.name}}</div>
                            <div class="main">
                                <el-checkbox-group v-model="integralList">
                                    <el-checkbox :label="item.name" name="type" :disabled="modification"></el-checkbox>
                                </el-checkbox-group>
                                <p v-if="integralList.includes(item.name)">使用
                                    <el-input :disabled="modification" type="text" style="width: 250px;margin: 0 15px" v-model="item.number" placeholder="0-99999"></el-input>积分可升级，<span class="text">{{item.title}}</span></p>
                            </div>
                        </div>
                    </div>
                    <div v-show="activeIndex==5">
                        <div v-for="(item,index) in removeCard" :key="index" class="birthday">
                            <div class="op_title">{{item.name}}</div>
                            <div class="main">
                                <el-checkbox-group v-model="removeCardList">
                                    <el-checkbox :label="item.name" name="type" :disabled="modification"></el-checkbox>
                                </el-checkbox-group>
                                <p v-if="removeCardList.includes(item.name)"><span class="text">{{item.title}}</span></p>
                            </div>
                        </div>
                    </div>
                    <div style="text-align:right;margin-bottom:20px" v-show="activeIndex==3||activeIndex==4||activeIndex==5">
                        <div v-show="!modification">
                            <el-button @click="clearSaveDate" type="primary" size="small">取消</el-button>
                            <el-button @click="saveDate" type="primary" size="small">保存</el-button>
                        </div>

                        <el-button v-show="modification" type="primary"  size="small" @click="alter">修改</el-button>
                    </div>
                </div>
            </div>

            <!-- 弹框 -->
            <el-dialog  :title="dialogTitle" :visible.sync="addTypeDialog" width="1200px" :before-close="closeDialoig">
                <div class="main">
                    <div class="op_title" style="margin-top: 0">已选择  <span style="color: #ccc;font-size: 14px">最多可选择5份商品/券</span></div>
                    <el-table stripe highlight-current-row :data="grantsFrom.distributionList" border size="mini" class="table">
                        <el-table-column align="center" label='序号' width="50">
                            <template slot-scope="scope">{{scope.$index+1+(currentPage-1)*20}}</template>
                        </el-table-column>
                        <el-table-column align="center" label="商品名称" prop="name"></el-table-column>
                        <el-table-column align="center" label="类型" prop="type_name"></el-table-column>
                        <el-table-column align="center" label="有效期" prop="time"></el-table-column>
                        <el-table-column align="center" label="更新时间" prop="update_time"></el-table-column>
                        <el-table-column align="center" label="限购数量" prop="limit_num"></el-table-column>
                        <el-table-column align="center" label='操作'>
                            <template slot-scope="scope">
                                <el-button type="danger" size="mini" @click="delRelevance(scope.$index)">移除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div class="op_title" >选择商品/券</div>
                    <el-form :inline="true" :model="relevanceFrom" ref="relevanceForm" size="small">
                        <el-form-item>
                            <el-select
                                    v-model="relevanceFrom.sell_type"
                                    style="width:100px"
                                    @change="relevanceFromType"
                                    filterable
                            >
                                <el-option
                                        v-for="item in relevance_list"
                                        :key="item.id"
                                        :label="item.name"
                                        :value="item.id"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item>
                            <span style="color: #888;">类型：</span>
                            <el-select
                                    v-model="relevanceFrom.type"
                                    style="width:100px"
                                    filterable
                            >
                                <el-option
                                        v-for="item in relevance_type"
                                        :key="item.id"
                                        :label="item.name"
                                        :value="item.id"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item prop="name">
                            <el-input
                                    v-model="relevanceFrom.name"
                                    placeholder="请输入商品名称"
                                    @keyup.enter.native="commodity"
                            ></el-input>
                        </el-form-item>
                        <el-form-item>
                            <dj-button size="small" @search="commodity">
                                <template #default>搜索</template>
                            </dj-button>
                        </el-form-item>
                    </el-form>
                    <el-table highlight-current-row :data="relevancelist" border size="mini" max-height="250px"  v-loading.body="listLoading">
                        <el-table-column align="center" label='序号' width="50">
                            <template slot-scope="scope">{{scope.$index+1+(currentPage-1)*20}}</template>
                        </el-table-column>
                        <el-table-column align="center" label="商品名称" prop="name"></el-table-column>
                        <el-table-column align="center" label="类型" prop="type_name"></el-table-column>
                        <el-table-column align="center" label="有效期" prop="time"></el-table-column>
                        <el-table-column align="center" label="更新时间" prop="update_time"></el-table-column>
                        <el-table-column align="center" label='操作'>
                            <template slot-scope="scope">
                                <el-button :disabled="grantsFrom.distributionList.length >=5"  type="primary" size="mini" @click="addRelevance(scope.row)">添加</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination
                            background
                            @current-change="relevanceCurrentChange"
                            :current-page.sync="relevancePage"
                            :page-size="20"
                            layout="prev, pager, next, jumper"
                            :page-count="relevanceTotal"
                            style="margin-top: 5px"
                    ></el-pagination>
                    <div style="text-align:right;margin-bottom:20px">
                        <el-button @click="saveClick"  type="primary" size="small">保存</el-button>
                    </div>
                </div>

                <!-- 弹框 -->
                <el-dialog  title="限购数量" :visible.sync="addTypeDialog1" append-to-body width="30%" :before-close="closeDialoig1">
                    <el-form>
                        <el-form-item label="名称：">
                            <span>{{distributionDate.name}}</span>
                        </el-form-item>
                        <el-form-item label="限购：">
                            <el-input type="text" v-model="grantsFrom.limit_num" style="width: 88%" placeholder="1-99999"></el-input>
                        </el-form-item>
                    </el-form>
                    <div class="main_botton" >
                        <span></span>
                        <el-button  type="primary" @click="dialogClick()">确定</el-button>
                    </div>
                </el-dialog>

            </el-dialog>

        </div>
    </div>
</template>

<script>
    import {
        getStore,
        vipWelfareSelect,
        goods_page,
        goods_list,
        vipWelfareUpdate
    } from "@/api/operation/member_benefits";

    import {
        num1to999999,
        multiple0to10Yi,
        integer0to999999
    } from "@/utils/validate";

    import { getGoodsType } from '@/utils';
    export default {
        name: "member_benefits",
        data(){
            return{
                store_list:null,
                store_id:"",
                oldActiveIndex:"",
                activeIndex:'1',
                modificationIndex:"",
                birthday:[{name:"一般用户",title:"指一张激活状态的普通会员卡或精英会员卡都没有的用户",card_type_id:"0",list:[]},
                    {name:"普通会员卡用户",title:"指拥有至少一张激活状态的普通会员卡的用户",card_type_id:"2",list:[]},
                    {name:"精英会员卡用户",title:"指拥有至少一张激活状态的精英会员卡的用户",card_type_id:"3",list:[]},],
                applyCard:[{name:"临时卡",title:"",card_type_id:"1",list:[]},
                    {name:"普通会员卡",title:"",card_type_id:"2",list:[]},
                    {name:"精英会员卡",title:"",card_type_id:"3",list:[]},],
                colorFilmList:[],
                colorFilm:[{name:"临时卡",title:"指当前卡类型使用彩豆（票）进行礼品兑换时，在非会员票数（临时卡）上可享受多少折扣",card_type_id:"1",number:"",support:""},
                    {name:"普通会员卡",title:"指当前卡类型使用彩豆（票）进行礼品兑换时，在会员票数（普通会员卡）上可享受多少折扣",card_type_id:"2",number:"",support:""},
                    {name:"精英会员卡",title:"指当前卡类型使用彩豆（票）进行礼品兑换时，在会员票数（精英会员卡）上可享受多少折扣",card_type_id:"3",number:"",support:""},],
                integralList:[],
                integral:[{name:"普通会员卡",title:"指低等级的卡使用相应积分可升级到当前等级",card_type_id:"2",number:"",support:""},
                    {name:"精英会员卡",title:"指低等级的卡使用相应积分可升级到当前等级",card_type_id:"3",number:"",support:""},],
                removeCardList:[],
                removeCard:[{name:"普通会员卡",title:"用户在自助机取卡成功后，自动通知到PC收银台",card_type_id:"2",support:"",number:""},
                    {name:"精英会员卡",title:"用户在自助机取卡成功后，自动通知到PC收银台",card_type_id:"3",support:"",number:""},],

                modification:true,
                card_type_id:"",

                // 以下弹框内容
                dialogTitle:"",
                listLoading:false,
                addTypeDialog: false, // 弹窗是否显示
                addTypeDialog1: false, // 弹窗是否显示
                distributionDate:"",  //当前选择的数据
                grantsFrom:{
                    limit_num:"",
                    distributionList:[], //弹窗分销数据
                },
                relevancelist:[],
                currentPage: 1,
                relevancePage: 1,
                relevanceTotal: 0,
                relevance_list:[{ id: "", name: "全部" },{ id: "1", name: "优惠券" },{ id: "2", name: "商品" },],
                relevance_type:[],
                type_list1: [
                    { id: "0", name: "全部" },
                    { id: "2", name: "办卡" },
                    { id: "3", name: "充值" },
                    { id: "4", name: "续期" },
                    { id: "5", name: "门票" },
                    { id: "6", name: "企划" },
                    { id: "7", name: "实物" },
                ],
                con_type_list: [
                    { id: "1", name: "代金券" },
                ],
                relevanceFrom:{ //商品搜索
                    type:"",
                    name: "",
                    sell_type:"",
                    store_id:""
                },
                // 以上弹框内容
            }
        },
        created() {
            this.getstore();
        },
        watch:{
            activeIndex:{
                handler(oldValue,NewValue){
                    this.oldActiveIndex = oldValue;
                }
            }
        },
        methods:{
            getstore() {
                getStore({ category_id: 718 }).then((response) => {
                    this.store_list = response;
                    let data = response.filter(
                        res => res.id == this.$store.getters.optionId
                    );
                    if (data.length > 0) {
                        this.store_id = data[0].id;
                        this.relevanceFrom.store_id = this.store_id;
                    }
                }).then(()=>{
                    this.listArray();
                });
            },
            storeClearDate(){  // 切换门店，数据清空
                for(let i=0;i<3;i++){
                    this.birthday[i].list = [];
                    this.applyCard[i].list = [];
                    this.colorFilm[i].number = "";
                    this.colorFilm[i].support = "";
                    if(this.integral[i] != undefined){
                        this.integral[i].number = "";
                        this.integral[i].support = "";
                    }
                    if(this.removeCard[i] != undefined){
                        this.removeCard[i].support = "";
                    }
                }
                this.relevanceFrom.store_id = this.store_id;
                this.modificationIndex = "";
                this.colorFilmList = [];
                this.integralList = [];
                this.removeCardList = [];
                this.activeIndex = '1';
                this.listArray();
            },
            listArray(){ // 数据获取
                vipWelfareSelect({
                    store_id:this.store_id,
                    type:this.activeIndex
                }).then(res=>{
                    if(this.activeIndex == 1){
                        if(res.data.length > 0){
                            for(let i=0;i<res.data.length;i++){
                                for(let j=0;j<this.birthday.length;j++){
                                    if(this.birthday[j].card_type_id == res.data[i].card_type_id){
                                        this.birthday[j].list = this.getGoodsData( res.data[i].goods);
                                    }
                                }
                            }
                        }else{
                            for(let j=0;j<this.birthday.length;j++){
                                this.birthday[j].list = [];
                            }
                        }
                    }else if(this.activeIndex == 2){
                        if(res.data.length > 0){
                            for(let i=0;i<res.data.length;i++){
                                for(let j=0;j<this.applyCard.length;j++){
                                    if(this.applyCard[j].card_type_id == res.data[i].card_type_id){
                                        this.applyCard[j].list = this.getGoodsData( res.data[i].goods);
                                    }
                                }
                            }
                        }else{
                            for(let j=0;j<this.applyCard.length;j++){
                                this.applyCard[j].list = [];
                            }
                        }
                    }else if(this.activeIndex == 3){
                        if(res.data.length > 0){
                            for(let i=0;i<res.data.length;i++){
                                for(let j=0;j<this.colorFilm.length;j++){
                                    if(res.data[i].card_type_id == this.colorFilm[j].card_type_id && res.data[i].support != "0"){
                                        this.colorFilm[j].number =  res.data[i].number;
                                        this.colorFilmList.push(this.colorFilm[j].name);
                                    }
                                }
                            }
                        }else{
                            for(let j=0;j<this.colorFilm.length;j++){
                                this.colorFilm[j].number =  '';
                                this.colorFilmList=[];
                            }
                        }
                    }else if(this.activeIndex == 4){
                        if(res.data.length > 0){
                            for(let i=0;i<res.data.length;i++){
                                for(let j=0;j<this.integral.length;j++){
                                    if(res.data[i].card_type_id == this.integral[j].card_type_id && res.data[i].support != "0"){
                                        this.integral[j].number =  res.data[i].number * 1;
                                        this.integralList.push(this.integral[j].name);
                                    }
                                }
                            }
                        }else{
                            for(let j=0;j<this.integral.length;j++){
                                this.integral[j].number =  "";
                                this.integralList = [];
                            }
                        }
                    }else if(this.activeIndex == 5){
                        if(res.data.length > 0){
                            for(let i=0;i<res.data.length;i++){
                                for(let j=0;j<this.removeCard.length;j++){
                                    if(res.data[i].card_type_id == this.removeCard[j].card_type_id && res.data[i].support != "0"){
                                        this.removeCardList.push(this.removeCard[j].name);
                                    }
                                }
                            }
                        }else{
                            for(let j=0;j<this.removeCard.length;j++){
                                this.removeCardList = [];
                            }
                        }
                    }
                });
            },
            addBirthday(title,index){
                this.commodity();
                this.dialogTitle = title;
                this.addTypeDialog = true;
                this.modification = false;
                if(this.activeIndex == 1){
                    this.card_type_id = this.birthday[index].card_type_id;
                }else {
                    this.card_type_id = this.applyCard[index].card_type_id;
                }
            },
            alterDialog(title,index){
                this.commodity();
                this.modification = true;
                this.addTypeDialog = true;
                this.addTypeDialog = true;
                this.dialogTitle = `${title} - 修改`;
                if(this.activeIndex == 1){
                    this.card_type_id = this.birthday[index].card_type_id;
                    this.grantsFrom.distributionList = JSON.parse(JSON.stringify(this.birthday[index].list));
                }else {
                    this.card_type_id = this.applyCard[index].card_type_id;
                    this.grantsFrom.distributionList = JSON.parse(JSON.stringify(this.applyCard[index].list));
                }
            },
            alter(){
                this.modification = false;
            },
            inputValue(index){
                if(!multiple0to10Yi(this.colorFilm[index].number)){
                    this.$message.error("最多可输入一位小数");
                }
            },
            saveDate(){ // 3-4-5 保存数据
                let json_list = [];
                let arrAy = [];
                let Array = [];
                if(this.activeIndex == 3){
                    arrAy = this.colorFilmList;
                    Array = this.colorFilm;
                    for(let i=0;i<arrAy.length;i++){
                        for(let j=0;j<Array.length;j++){
                            if(arrAy[i] == Array[j].name && !multiple0to10Yi(Array[j].number)){
                                this.$message.error(`请输入正确的享受折扣(最多一位小数)`);
                                return
                            }
                        }
                    }
                }
                if(this.activeIndex == 4){
                    arrAy = this.integralList;
                    Array = this.integral;
                    for(let i=0;i<arrAy.length;i++){
                        for(let j=0;j<Array.length;j++){
                            if(arrAy[i] == Array[j].name && !integer0to999999(Array[j].number)){
                                this.$message.error(`请输入正确的积分`);
                                return
                            }
                        }
                    }
                }

                if(this.activeIndex == 5){
                    arrAy = this.removeCardList;
                    Array = this.removeCard;
                }

                for(let i=0;i<arrAy.length;i++){
                    for(let j=0;j<Array.length;j++){
                        if(arrAy[i] == Array[j].name){
                            Array[j].support = "1";
                        }
                    }
                }
                Array.forEach(val=>{
                    if(arrAy.join('').indexOf(val.name) == -1){
                        val.number = "";
                        val.support = "0";
                    }
                })


                for(let i=0;i<Array.length;i++){
                    var support = Array[i].support==1?'1':'0';
                    json_list.push({
                        card_type_id:Array[i].card_type_id,
                        number:Array[i].number,
                        support:support,
                    })
                }

                let data = {
                    store_id:this.store_id,
                    type:this.activeIndex,
                    the_345:json_list,
                }

                // console.log(data);

                vipWelfareUpdate(data).then(res=>{
                    if(res.code==1){
                        this.clearDate();
                        this.modification = true;
                        this.$message.success(res.message);
                        this.listArray();
                    }
                })
            },
            clearSaveDate(){
                this.$confirm("尚未保存，取消后数据清空，是否确定？", "提示", {
                    type: "warning"
                }).then(() => {
                    this.modification = true;
                    this.listArray();
                }).catch(()=>{
                    this.modification = false;
                });
            },
            handleSelect(key, keyPath) {
                if(this.activeIndex != key){
                    if(!this.modification){
                        this.$confirm("数据尚未保存，是否继续切换", "提示", {
                            type: "warning"
                        }).then(() => {
                            this.modification = true;
                            if(this.activeIndex != key){
                                this.activeIndex = key;
                                this.listArray();
                            }
                        }).catch(()=>{
                            this.modification = false;
                            this.activeIndex = Number(this.oldActiveIndex);
                        });
                    }else{
                        this.activeIndex = key;
                        this.listArray();
                    }
                }
            },
            //以下为弹框
            saveClick(){
                let json_list=[];
                if(!this.modification){
                    if(this.grantsFrom.distributionList.length<1){
                        this.$message.error("请选择关联的商品/券");
                        return
                    }
                }

                if(!this.modificationIndex){
                    this.$message.error("该福利没有做任何修改");
                    return
                }

                if(this.activeIndex ==  1 || this.activeIndex == 2){
                    if(this.grantsFrom.distributionList.length>0){
                        for(let i=0;i<this.grantsFrom.distributionList.length;i++){
                            var id = this.grantsFrom.distributionList[i].id?this.grantsFrom.distributionList[i].id:this.grantsFrom.distributionList[i].goods_id;
                            json_list.push({
                                goods_id: id,
                                limit_num:this.grantsFrom.distributionList[i].limit_num,
                            })
                        }
                    }else {
                        json_list.push({
                            goods_id: '',
                            limit_num:'',
                        })
                    }
                }

                let data = {
                    store_id:this.store_id,
                    card_type_id:this.card_type_id,
                    type:this.activeIndex,
                    json_list:json_list
                };

                // console.log(data)

                vipWelfareUpdate(data).then(res=>{
                    if(res.code==1){
                        this.clearDate();
                        this.addTypeDialog = false;
                        this.$message.success(res.message);
                        this.listArray();
                    }
                })
            },
            addRelevance(row){ //添加商品
                this.modificationIndex = "1";
                if(this.grantsFrom.distributionList.length>=1){
                    for(let i=0;i<this.grantsFrom.distributionList.length;i++){
                        if(row.name == this.grantsFrom.distributionList[i].name){
                            this.$message.error("已添加成功，请勿重复添加");
                            return
                        }
                    }
                    this.distributionDate = row;
                    this.addTypeDialog1 = true;
                }else{
                    this.distributionDate = row;
                    this.addTypeDialog1 = true;
                }
            },
            delRelevance(index){ //移除商品
                this.modificationIndex = "1";
                this.grantsFrom.distributionList.splice(index, 1);
            },
            dialogClick(){
                if(num1to999999(this.grantsFrom.limit_num)){
                    this.distributionDate.limit_num = this.grantsFrom.limit_num;
                    this.grantsFrom.distributionList = [...this.grantsFrom.distributionList,...[this.distributionDate]];
                    this.distributionDate = "";
                    this.grantsFrom.limit_num = "";
                    this.addTypeDialog1 = false;
                }else{
                    this.$message.error("请填写正确的限购数量");
                }
            },
            commodity(){
                this.listLoading = true;
                this.relevancelist = [];
                // console.log(this.relevanceFrom)
                goods_page(this.relevanceFrom).then(response=>{
                    this.relevanceTotal = response.data.page / 1;
                    if (this.relevanceTotal == 0) {
                        this.listLoading = false;
                    } else {
                        goods_list(this.relevanceFrom).then(res=>{
                            this.relevancelist =  this.getGoodsData(res.data);
                            this.listLoading = false;
                        });
                    }
                });
            },
            getGoodsData(data) {
                data.forEach((val) => {
                    val.type_name = getGoodsType(val.type?val.type:val.second_type);
                    val.time =
                        val.chose_time_type == 1
                            ? val.effect_time.replace(/-/g, ".").replace(/,/g, "-")
                            : val.effect_time > 0
                            ? "购买后" + val.effect_time + "天内有效"
                            : "";
                    val.time = val.time
                        ? val.time
                        : val.effect_time === "0"
                            ? "购买后当天有效"
                            : "购买后立即生效";
                });
                return data;
            },
            relevanceCurrentChange(val){
                this.listLoading = true;
                goods_list(this.relevanceFrom,val).then(res=>{
                    this.relevancelist =  this.getGoodsData(res.data);
                    this.listLoading = false;
                });
            },
            relevanceFromType(){
                if(this.relevanceFrom.sell_type=="2"){
                    this.relevance_type=this.type_list1;
                    this.relevanceFrom.type='0';
                }else if(this.relevanceFrom.sell_type=="1"){
                    this.relevance_type=this.con_type_list;
                    this.relevanceFrom.type='1';
                }else{
                    this.relevanceFrom.type='';
                }
            },
            closeDialoig1(){
                this.$confirm("尚未保存，关闭后数据清空，是否关闭", "提示", {
                    type: "warning"
                }).then(() => {
                    this.distributionDate = "";
                    this.grantsFrom.limit_num = "";
                    this.addTypeDialog1 = false;
                }).catch(()=>{
                    this.addTypeDialog1 = true;
                });
            },
            closeDialoig(){
                this.$confirm("尚未保存，关闭后数据清空，是否关闭", "提示", {
                    type: "warning"
                }).then(() => {
                    this.clearDate();
                    this.modification = true;
                    this.addTypeDialog = false;
                }).catch(()=>{
                    this.addTypeDialog = true;
                });
            },
            clearDate(){
                this.modification = true;
                this.distributionDate = "";
                this.card_type_id = "";
                this.modificationIndex = "";
                this.integralList = [];
                this.colorFilmList = [];
                this.removeCardList = [];
                this.grantsFrom={
                    limit_num:"",
                    distributionList:[], //弹窗分销数据
                }
            },
            //以上为弹框
        }
    }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
    .customContainer {
        overflow-y: auto;
    }
    .store{
        padding: 8px 15px;
        min-width: 1040px;
    }
    .centent{
        padding: 20px;
        box-sizing: border-box;

        .birthday{
            margin-bottom: 15px;

            .op_title {
                margin-bottom: 15px;
                font-size: 17px;
                font-weight: bold;
                color: #282828;
                padding:0 0 10px 0px;
                box-sizing: border-box;
                border-bottom: 1px solid #dcdfe6;
                display: flex;
                align-items: center;

                span:nth-child(1){
                    display: block;
                    width: 120px;
                }

                button{
                    width: 100px;
                    height: 35px;
                    line-height: 35px;
                    margin: 0 15px 0 30px;
                    padding: 0;
                }
            }
            .table{
                max-width: 1200px;
            }
        }
        .text{
            font-size: 14px;
            color: #909399;
        }
        .main{
            display: flex;
            align-items: center;
            height: 60px;
            .el-checkbox-group{
                width: 100px;
            }

            p{
                width: 100%;
                display: flex;
                align-items: center;
                margin-left: 50px;
            }
        }
    }

    .main_botton{
        margin-top: 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;

        button{
            width: 100px;
            height: 35px;
            line-height: 10px;
        }
    }
    .op_title {
        margin: 30px 0 20px;
        font-size: 18px;
        font-weight: bold;
        color: #282828;
        padding:0 0 10px 0px;
        box-sizing: border-box;
        border-bottom: 1px solid #dcdfe6;
    }
    .el-menu-item{
        font-size: 15px;
    }
    .el-menu--horizontal>.el-menu-item.is-active{
        font-weight: bold;
    }
    .el-menu--horizontal>.el-menu-item.is-active{
        border-bottom: 4px solid #409EFF;
    }
</style>